package cn.shutdown.farm.service.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.shutdown.farm.dao.PlantRepository;
import cn.shutdown.farm.model.Plant;
import cn.shutdown.farm.service.PlantServiceI;

@Service("plantService")
@Transactional
public class PlantServiceImpl implements PlantServiceI {

	private static final Logger logger = Logger
			.getLogger(PlantServiceImpl.class);

	@Autowired
	private PlantRepository plantRepository;

	@Override
	public Plant create(Plant plant) {
		return plantRepository.save(plant);
	}

	@Override
	public Plant update(Plant plant) {
		return plantRepository.save(plant);
	}

	@Override
	public void delete(Plant plant) {
		plantRepository.delete(plant);
	}

	@Override
	public Plant findOne(String id) {
		return plantRepository.findOne(id);
	}
	
	@Override
	public List<Plant> findAll(){
		return plantRepository.findAll();
	}
	
	@Override
	public void delete(String id){
		plantRepository.delete(id);
	}

	public PlantRepository getPlantRepository() {
		return plantRepository;
	}

	public void setPlantRepository(PlantRepository plantRepository) {
		this.plantRepository = plantRepository;
	}

}
